package main

import (
	"emsctrl/apicmd"
	"emsctrl/util"
	"fmt"
)

func main() {

	//timsStr := "10:10:10"
	//parse, err := time.Parse("15:04:05", timsStr)
	//if err != nil {
	//	fmt.Println(err)
	//}
	//fmt.Println(parse)
	//dateStr := "2024-05-29"
	//t, err := time.Parse("2006-01-02", dateStr)
	//fmt.Println(t)
	//interval := util.CompareDateInterval("2024-05-30", "2024-05-29")
	//fmt.Println(interval)
	//day := t.Weekday()
	//fmt.Println(int(day))
	mng := apicmd.Price_cfg_mng{}
	err := util.JsonReadFile("/conf/price.json", &mng)
	if err != nil {
		fmt.Println(err)
	}
	fmt.Println(mng)
}

var g_priceCfg apicmd.Price_cfg_table

func PriceInit() {
	table := apicmd.Price_time_table{}
	table.StartTime = "00:00:00"
	table.EndTime = "06:00:00"
	table.Price = 0.3
	g_priceCfg.Time = append(g_priceCfg.Time, table)
	table.StartTime = "06:00:00"
	table.EndTime = "08:00:00"
	table.Price = 0.9
	g_priceCfg.Time = append(g_priceCfg.Time, table)
	table.StartTime = "08:00:00"
	table.EndTime = "11:00:00"
	table.Price = 1.3
	g_priceCfg.Time = append(g_priceCfg.Time, table)
	table.StartTime = "11:00:00"
	table.EndTime = "13:00:00"
	table.Price = 0.7
	g_priceCfg.Time = append(g_priceCfg.Time, table)
	table.StartTime = "13:00:00"
	table.EndTime = "16:00:00"
	table.Price = 1.5
	g_priceCfg.Time = append(g_priceCfg.Time, table)
	table.StartTime = "16:00:00"
	table.EndTime = "20:00:00"
	table.Price = 0.5
	g_priceCfg.Time = append(g_priceCfg.Time, table)
	table.StartTime = "20:00:00"
	table.EndTime = "23:59:59"
	table.Price = 0.3
	g_priceCfg.Time = append(g_priceCfg.Time, table)
	fmt.Println(g_priceCfg)
}

func PolicyGen() {

}

//func JsonReadFile(filename string, Result interface{}) error {
//	dir, _ := os.Getwd()
//	open, err := os.Open(dir + filename)
//	if err != nil {
//		fmt.Println(err)
//		return err
//	}
//	buf, err := io.ReadAll(open)
//	err = json.Unmarshal(buf, Result)
//	if err != nil {
//		fmt.Println(err)
//	}
//	return err
//}
